import request from '@/utils/request';
import type { BaseBeanModel, ResponsePageData, ResponseBaseData } from '@/api/model/baseModel';
import type { downloadParam } from '@/utils/download-util';
import { download } from '@/utils/download-util';
const basePath = '/appsys/sysautocode/SysAutoCodeManageRest';

/** 编码定义表主表 */
export interface SysAutoCodeDto extends BaseBeanModel {
  /** 自动编号代码 */
  code?: string;
  /** 自动编号名称 */
  name?: string;
  /** 编码样式 */
  style?: string;
}

/** 获取分页数据 */
export function listSysAutoCodeByPage(param: any): Promise<ResponsePageData<SysAutoCodeDto>> {
  return request.post(`${basePath}/searchByPage/v1`, param);
}

/** 根据id加载数据 */
export function getSysAutoCode(id: string): Promise<ResponseBaseData<any>> {
  return request.get(`${basePath}/getData/v1/${id}`);
}

/** 保存表单数据 */
export function saveSysAutoCode(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/save/v1`, param);
}

/** 更新表单数据 */
export function updateSysAutoCode(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/update/v1`, param);
}
/** 根据id集合删除数据 */
export function delSysAutoCode(ids: [string]): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/deleteByIds/v1`, ids);
}
/** 编码代码唯一性校验 */
export function checkAutoCode(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/getSysAutoCodeByCode/v1`, param);
}

/** 检查通用代码 */
export function checkLooukupCode(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/checkLooukupCode/v1`, param);
}
/** sql校验 */
export function checkSqlExp(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/checkSqlExp/v1`, param);
}
/** rest服务名校验 */
export function checkRestServicesName(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/checkRestServicesName/v1`, param);
}
/** rest服务地址校验 */
export function checkRestServicesURL(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/checkRestServicesURL/v1`, param);
}
/** 预览编码 */
export function previewAutoCode(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/previewAutoCode/v1`, param);
}

/** 获取数据源 */
export function listDataSource(param: any): Promise<ResponseBaseData<any>> {
  return request.post('/platform6/connectcenter/connectrest/getConnectObjectMap/v1', param);
}
/** 导出Excel */
export function exportExcel(param: any) {
  const downloadData = {
    url: `${basePath}/export-xml/v1`,
    data: param,
    method: 'post'
  } as downloadParam;
  return download(downloadData);
}
